package com.appspot.gaeforum309.pathing;

import java.util.List;

import com.appspot.gaeforum309.pathing.PathBuilder.IPathable;

public class Path {
	private final List<IPathable> path;

	Path(List<IPathable> path) {
		this.path = path;
	}

	public List<IPathable> getPath() {
		return path;
	}

	public String objectTagName() {
		IPathable iobject = path.get(0);
		if (iobject == null)
			return null;

		return iobject.getPathable().getTagName();
	}
	
	public IPathable object()
	{
		return path.get(0);
	}
	
	public IPathable getObjectByTagName(String tagName)
	{
		if(tagName == null)
			return null;
		
		for(IPathable ip: path)
		{
			if(ip.getPathable().getTagName().equals(tagName))
				return ip;
		}
		
		return null;
	}
}
